package data.join.com.database;

import android.app.Application;

import java.util.List;

import data.join.com.database.bean.DaoMaster;
import data.join.com.database.bean.DaoSession;
import data.join.com.database.bean.DataBean;


/**
 * Created by Administrator on 2017/3/23.
 */

public class GreenDao {

    private static GreenDao greenDao;

    public DaoSession sDaoSession;

    private GreenDao(Application app){
        MySQLiteOpenHelper devOpenHelper = new MySQLiteOpenHelper(app, "record.db", null);
        DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
        sDaoSession = daoMaster.newSession();
    }

    public static void init(Application app){
        greenDao = new GreenDao(app);
    }

    public static GreenDao getInstance(){
        return greenDao;
    }

    public void insertDataBean(DataBean dataBean){
        sDaoSession.getDataBeanDao().insert(dataBean);
    }
}
